/*
 * @: 
 * @Version: 1.0
 * @Autor: ziwei
 * @Date: 2021-11-01 18:46:44
 * @LastEditors: ziwei
 * @LastEditTime: 2021-11-01 18:49:52
 */
import { CALL_HISTORY_METHOD } from "./push";

function routerMiddleware(history) {
  return function () {
    return function (next) {
      return function (action) {
        //自己能处理
        if(action.type === CALL_HISTORY_METHOD){
          const {payload:{method,path}} = action
          history[method](path)
        }else{
          //自己处理不了
          next(action)
        }
      }
    }
  }
}

export default routerMiddleware